//
//  ImageDetailViewController.swift
//  photoTool
//
//  Created by 刘清元 on 2022/8/27.
//

import UIKit
import SnapKit
import Photos
class ImageDetailViewController: UIViewController {

    public var imageModel = ImageModel.init(){
        didSet{
            let assetResult = PHAsset.fetchAssets(withLocalIdentifiers: [imageModel.localIdentifier!], options: nil)
            if let asset = assetResult.firstObject{
                PHImageManager.default().requestImage(for: asset, targetSize: CGSize(width: imageModel.width!, height: imageModel.height!), contentMode: .aspectFill, options: nil) { image, info in
                    self.contentImg.image = image
                }
            }
        }
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
    }
    
    lazy var contentImg: UIImageView = {
        let image = UIImageView.init()
        view.addSubview(image)
        image.contentMode = .scaleAspectFill
        image.snp.makeConstraints { make in
            make.edges.equalToSuperview()
        }
        return image
    }()
}
